package com.cindata

import com.cindata.dictionary.*

class Vehicle
{

    Province province
    City city
    District district
    EstateStatusDict estateStatus
    Boolean isEstate = true
    BigDecimal unitPrice
    // 评估单价
    BigDecimal totalPrice
    // 评估总价
    Date valuationDate
    // 评估时间
    BigDecimal ltv
    // 抵押率 （%）
    BigDecimal cltv
    // 动态抵押率 （%）
    Account account
    // 直属管理机构(银行网点)
    Mortgage mortgage
    // 贷款
    MortgageStatusDict mortgageStatus

    String externalId
    // 质押物编号
    String name
    // 质押物名称
    String fullName
    // 抵押人名称
    ContactIdentityType identityType
    // 抵押人证件类型
    String idNumber
    // 抵押人证件号码
    String loanCardNumber
    // 抵押人贷款卡编号
    String commonOwnerFullName
    // 其他共同所有人
    Double sharePoint
    // 所占份额

    Boolean isApplayPurchaseAsset = false
    // 此抵押物是否当前申请所购资产
    String rightOfMortgage
    // 抵押权顺位
    BigDecimal firstGuaranteedAmount
    // 在先担保金额
    String brand
    // 抵押物品牌（品牌）
    String manufacturer
    // 制造厂家
    String model
    // 车辆型号
    String engineNumber
    // 发动机号码
    String mortgageRegisterNo
    // 抵押登记证书编号（注册号）
    Date releaseDate
    // 生产日期
    Date purchaseDate
    // 购置日期
    Double purchasePrice
    //购置价格
    CurrencyDict currency
    // 币种
    String usage
    // 使用情况 1出租 2自用 3其他
    String lessee
    // 承租人
    Date leaseStartDate
    // 租赁起始日期
    Date leaseEndDate
    // 租赁到期日期
    Double dailyRents
    // 日租金（元）

    Cashability cashability
    // 变现能力 1.通用且变现容易，2.通用但变现较不易，专用性强
    String valueVolatility
    // 价值波动性 1.价值波动大；2.价值波动中；3.有升值潜力或波动小
    String seizureOfConvenience
    // 查封便利性 1.无查封障碍的不动产，动产由我行监管；2.查封有一定障碍的不动产，动产存放地点相对固定但非我行监管；3.查封有障碍的不动产，动产存放地点难掌握和控制
    String relationOfMortgagor
    // 抵质押物与借款人相关性 1.本人 2.第三方
    String legalValidity
    // 法律有效性 1.担保合法且手续完整 2.担保不合法或手续基本无效
    Double firstEvaluatePrice
    // 初次评估价值
    Account firstEvaluateAccount
    // 初次评估机构
    Double latestEvaluatePrice
    // 最新评估价值
    Account latestEvaluateAccount
    // 最新评估机构
    Date latestEvaluateDate
    // 最新评估日期
    Date nextEvaluateDate
    // 下次评估日期
    Double actualMortgageRate
    // 实际抵质押率 (实际抵质押率=债权本息总额÷抵押物评估价值（或质押物认定价值）×100%)
    Double mortgageRateUpperLimit
    // 抵质押率上限
    String description
    // 抵质押物说明
    String registerFullName
    // 登记人
    String registerAccount
    // 登记机构
    Date registerDate
    // 登记日期
    Date registerUpdateDate
    // 更新日期

    VehicleTypeDict type
    // 车辆类型
    String mileage
    // 行驶里程
    String plateNumber
    // 车牌号
    String identificationNumber
    // 车架号
    Boolean isNew = false
    // 是否新车
    String condition
    // 车辆状况

    Date createdDate = new Date()
    Date modifiedDate = new Date()
    User user
    User createBy
    User modifyBy

    static constraints = {

        province nullable: true, blank: true, comment: '省份'
        city nullable: true, blank: true, comment: '城市'
        district nullable: true, blank: true, comment: '区县'
        estateStatus nullable: true, blank: true, comment: '贷款状态'
        isEstate nullable: true, blank: true, comment: '是否在押'
        unitPrice nullable: true, blank: true, comment: '评估单价'
        totalPrice nullable: true, blank: true, comment: '评估总价'
        valuationDate nullable: true, blank: true, comment: '评估时间'
        ltv nullable: true, blank: true, comment: '抵押率 （%）'
        cltv nullable: true, blank: true, comment: '动态抵押率 （%）'
        account nullable: true, blank: true, comment: '属管理机构(银行网点)'
        mortgage nullable: true, blank: true, comment: '贷款'
        mortgageStatus nullable: true, blank: true, comment: '贷款状态'

        externalId nullable: true, blank: true, comment: '质押物编号'
        name nullable: true, blank: true, comment: '质押物名称'
        fullName nullable: true, blank: true, comment: '抵押人名称'
        identityType nullable: true, blank: true, comment: '抵押人证件类型'
        idNumber nullable: true, blank: true, comment: '抵押人证件号码'
        loanCardNumber nullable: true, blank: true, comment: '抵押人贷款卡编号'
        commonOwnerFullName nullable: true, blank: true, comment: '其他共同所有人'
        sharePoint nullable: true, blank: true, comment: '所占份额'

        isApplayPurchaseAsset nullable: true, blank: true, comment: '此抵押物是否当前申请所购资产'
        rightOfMortgage nullable: true, blank: true, comment: '抵押权顺位'
        firstGuaranteedAmount nullable: true, blank: true, comment: '在先担保金额'
        brand nullable: true, blank: true, comment: '抵押物品牌（品牌）'
        manufacturer nullable: true, blank: true, comment: '制造厂家'
        model nullable: true, blank: true, comment: '车辆型号'
        engineNumber nullable: true, blank: true, comment: '发动机号码'
        mortgageRegisterNo nullable: true, blank: true, comment: '抵押登记证书编号（注册号）'
        releaseDate nullable: true, blank: true, comment: '生产日期'
        purchaseDate nullable: true, blank: true, comment: '购置日期'
        purchasePrice nullable: true, blank: true, comment: '购置价格'
        currency nullable: true, blank: true, comment: '币种'
        usage nullable: true, blank: true, comment: '使用情况'
        lessee nullable: true, blank: true, comment: '承租人'
        leaseStartDate nullable: true, blank: true, comment: '租赁起始日期'
        leaseEndDate nullable: true, blank: true, comment: '租赁到期日期'
        dailyRents nullable: true, blank: true, comment: '日租金（元）'

        cashability nullable: true, blank: true, comment: '变现能力'
        valueVolatility nullable: true, blank: true, comment: '价值波动性'
        seizureOfConvenience nullable: true, blank: true, comment: '查封便利性'
        relationOfMortgagor nullable: true, blank: true, comment: '抵质押物与借款人相关性'
        legalValidity nullable: true, blank: true, comment: '法律有效性'
        firstEvaluatePrice nullable: true, blank: true, comment: '初次评估价值'
        firstEvaluateAccount nullable: true, blank: true, comment: '初次评估机构'
        latestEvaluatePrice nullable: true, blank: true, comment: '最新评估价值'
        latestEvaluateAccount nullable: true, blank: true, comment: '最新评估机构'
        latestEvaluateDate nullable: true, blank: true, comment: '最新评估日期'
        nextEvaluateDate nullable: true, blank: true, comment: '下次评估日期'
        actualMortgageRate nullable: true, blank: true, comment: '实际抵质押率'
        mortgageRateUpperLimit nullable: true, blank: true, comment: '抵质押率上限'
        description maxSize: 512, nullable: true, blank: true, comment: '抵质押物说明'
        registerFullName nullable: true, blank: true, comment: '登记人'
        registerAccount nullable: true, blank: true, comment: '登记机构'
        registerDate nullable: true, blank: true, comment: '登记日期'
        registerUpdateDate nullable: true, blank: true, comment: '更新日期'

        createdDate nullable: true, blank: true
        modifiedDate nullable: true, blank: true
        user nullable: true, blank: true
        createBy nullable: true, blank: true
        modifyBy nullable: true, blank: true

        type nullable: true, blank: true, comment: '车辆类型'
        mileage nullable: true, blank: true, comment: '行驶里程'
        plateNumber maxSize: 20, nullable: true, blank: true, comment: '车牌号'
        identificationNumber maxSize: 20, nullable: true, blank: true, comment: '车架号'
        isNew nullable: true, blank: true, comment: '是否新车'
        condition maxSize: 100, nullable: true, blank: true, comment: '车辆状况'
    }

    def springSecurityService

    def beforeUpdate()
    {
        modifiedDate = new Date()
        def username = springSecurityService?.getPrincipal()?.username
        modifyBy = User.findByUsername(username)
    }

    def beforeInsert()
    {
        def username = springSecurityService?.getPrincipal()?.username
        createBy = User.findByUsername(username)
        account = createBy?.account
    }
}
